//
//  VVStackTests.m
//  SideDemo
//
//  Created by zsp on 16/5/13.
//  Copyright © 2016年 zsp. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "VVStack.h"

@interface VVStackTests : XCTestCase{
    VVStack *stack;
}

@end

@implementation VVStackTests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
    stack =[VVStack new];
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    stack=nil;
    [super tearDown];
}

- (void)testStackExist {
    XCTAssertNotNil([VVStack class],@"VVStack class should exist.");
}


- (void)testStackObjectCanBeCreated {
    XCTAssertNotNil(stack,@"VVStack object can be created.");
}

- (void)testPushANumberAndGetIt {
    [stack push:2.3];
    double topNumber=[stack top];
    XCTAssertEqual(topNumber, 2.3,@"VVStack should should can be pushed and has that top number.");
}

- (void)testPushBNumberAndGetIt {
    [stack push:2.3];
    [stack push:4.6];
    double topNumber=[stack top];
    XCTAssertEqual(topNumber, 4.6,@"top number of VVStack should be the last number pushed into it.");
}

- (void)testPopANumber{
    [stack push:2.3];
    [stack push:4.6];
    double popNumber=[stack pop];
    XCTAssertEqual(popNumber, 4.6, @"pop number should be the last number pushed into VVStack");
}

- (void)testPopANumberFromEmptyStack{
    [stack push:2.3];
    double popNumber=[stack pop];
    XCTAssertEqual(popNumber, 0, @"pop number should be the last number pushed into VVStack");
}

- (void)testPopANumberFromNilStack{
    stack=nil;
    double popNumber=[stack pop];
    XCTAssertEqual(popNumber, 0, @"pop number should be the last number pushed into VVStack");
}

- (void)testCountFromEmptyStack {
    NSUInteger count=[stack count];
    XCTAssertEqual(count, 0, @"the count of empty VVStack should be 0.");
}

- (void)testCountFromNotEmptyStack {
    [stack push:2.3];
    [stack push:4.6];
    NSUInteger count=[stack count];
    XCTAssertEqual(count, 2, @"pop number should be the last number pushed into VVStack");
}

- (void)testCountFromNilStack {
    stack=nil;
    NSUInteger count=[stack count];
    XCTAssertEqual(count, 0, @"pop number should be the last number pushed into VVStack");
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

@end
